<template>
  <div id='MyAccount'>
    <div class='MyAccount_tas'>
      <div class='MyAccount_tas_right'>
        <el-input size='small' v-model.trim='input' class='input' type='text' @change="searchfile" placeholder='搜索文件'>
          <i slot='suffix' class='iconfont' style='margin-right:6px;cursor:pointer' @click="searchfile">&#xe61a;</i>
        </el-input>
        <el-button type='primary' v-if='documentjurisdiction.upload' round class='elBtn' @click="upload">上传文件</el-button>
        <el-button type='primary' v-if='documentjurisdiction.bitchdelete' round class='elBtn' @click="deletes">批量删除</el-button>
      </div>
    </div>
    <div class='MyAccount_count'>
      <management :bitchdelete="documentjurisdiction.bitchdelete" ref="management" :input="input"></management>
    </div>
  </div>
</template>
<script>
import management from './AccountViewAccountChildren/management';
import { mapState } from 'vuex';
export default {
  components: {
    management,
  },
  data () {
    return {
      itemName: '',
      input: '',
      isaccount: false,
      ifBossAudit: false,
      documentjurisdiction: {
        upload: false,
        bitchdelete: false
      }
    };
  },
  computed: {
    ...mapState({
      userInfo: state => state.common.userInfo,
      documentaccountid: state => state.companyInfo.documentaccountid
    })
  },
  methods: {
    searchfile () {
      this.$refs.management.Getthedocument();
    },
    upload () {
      this.$refs.management.isShow = true;
    },
    deletes () {
      this.$refs.management.completelyDelete();
    },
    getJurisdiction() {
      if(this.userInfo.isadmin) {
        this.documentjurisdiction = {
          upload: true,
          bitchdelete: true
        };
        return;
      }
      let params = {
        id: this.documentaccountid
      };
      this.$api.publicApi.GetActionInfo(params).then(res => {
        let resData = res.data.data;
        resData.forEach(item=>{
          if(item.name == "批量删除") {
            this.documentjurisdiction.bitchdelete = true;
          }
          if(item.name == "上传文件") {
            this.documentjurisdiction.upload = true;
          }
        });
      });
    }
  },
  created () {
    this.getJurisdiction();
  }
};
</script>
<style lang='less'>
#MyAccount {
  padding: 0;
  .MyAccount_tas {
    height: 60px;
    border-bottom: 1px solid #e0dcdc;
    .MyAccount_tas_left {
      float: left;
      margin-left: 30px;
      margin-top: 23px;
    }
    .MyAccount_tas_right {
      float: right;
      margin-right: 20px;
      line-height: 60px;
      .elBtn {
        width: 100px;
      }
      .el-input--small .el-input__inner {
        border-radius: 25px;
      }
      .el-input {
        width: 200px;
        font-size: 14px;
        display: inline-block;
        margin-right: 12px;
      }
    }
  }
  .MyAccount_count{
    width: 100%;
    height: calc(100% - 62px);
    // height: 100%;
    overflow: auto;
  }
}
</style>
